\doxysection{C\+:/\+Users/\+ASUS/\+Desktop/dm-\/ctrl\+H7-\/balance-\/9025test/modules/imu/ins\+\_\+task.c File Reference}
\hypertarget{ins__task_8c}{}\label{ins__task_8c}\index{C:/Users/ASUS/Desktop/dm-\/ctrlH7-\/balance-\/9025test/modules/imu/ins\_task.c@{C:/Users/ASUS/Desktop/dm-\/ctrlH7-\/balance-\/9025test/modules/imu/ins\_task.c}}
{\ttfamily \#include "{}ins\+\_\+task.\+h"{}}\newline
{\ttfamily \#include "{}controller.\+h"{}}\newline
{\ttfamily \#include "{}Quaternion\+EKF.\+h"{}}\newline
{\ttfamily \#include "{}spi.\+h"{}}\newline
{\ttfamily \#include "{}tim.\+h"{}}\newline
{\ttfamily \#include "{}user\+\_\+lib.\+h"{}}\newline
{\ttfamily \#include "{}general\+\_\+def.\+h"{}}\newline
\doxysubsubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
\Hypertarget{ins__task_8c_a5474fb69eaecdc5d0837dbf9790eb72c}\label{ins__task_8c_a5474fb69eaecdc5d0837dbf9790eb72c} 
\mbox{\hyperlink{structattitude__t}{attitude\+\_\+t}} \texorpdfstring{$\ast$}{*} {\bfseries INS\+\_\+\+Init} (void)
\begin{DoxyCompactList}\small\item\em 初始化惯导解算系统 \end{DoxyCompactList}\item 
\Hypertarget{ins__task_8c_a79b7240e8c7e0d5419282ca230c7a85e}\label{ins__task_8c_a79b7240e8c7e0d5419282ca230c7a85e} 
void {\bfseries INS\+\_\+\+Task} (void)
\begin{DoxyCompactList}\small\item\em 此函数放入实时系统中,以1k\+Hz频率运行 p.\+s. os\+Delay(1); \end{DoxyCompactList}\item 
void \mbox{\hyperlink{ins__task_8c_a151377c6cfa1152d7642d42cd7dd5d3d}{Body\+Frame\+To\+Earth\+Frame}} (const float \texorpdfstring{$\ast$}{*}vec\+BF, float \texorpdfstring{$\ast$}{*}vec\+EF, float \texorpdfstring{$\ast$}{*}q)
\begin{DoxyCompactList}\small\item\em Transform 3dvector from Body\+Frame to Earth\+Frame. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{ins__task_8c_add6f841604e6b40025533d6e58d74ac8}{Earth\+Frame\+To\+Body\+Frame}} (const float \texorpdfstring{$\ast$}{*}vec\+EF, float \texorpdfstring{$\ast$}{*}vec\+BF, float \texorpdfstring{$\ast$}{*}q)
\begin{DoxyCompactList}\small\item\em Transform 3dvector from Earth\+Frame to Body\+Frame. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{ins__task_8c_af69cef46084fc1f1f7f41a5e48f5a7e9}{Quaternion\+Update}} (float \texorpdfstring{$\ast$}{*}q, float gx, float gy, float gz, float dt)
\begin{DoxyCompactList}\small\item\em Update quaternion. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{ins__task_8c_a12a2c8b057bc73a18dc7765de080bd27}{Quaternion\+To\+Eular\+Angle}} (float \texorpdfstring{$\ast$}{*}q, float \texorpdfstring{$\ast$}{*}Yaw, float \texorpdfstring{$\ast$}{*}Pitch, float \texorpdfstring{$\ast$}{*}Roll)
\begin{DoxyCompactList}\small\item\em Convert quaternion to eular angle. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{ins__task_8c_ab9879d429b498cb40bfb7027a771d12b}{Eular\+Angle\+To\+Quaternion}} (float Yaw, float Pitch, float Roll, float \texorpdfstring{$\ast$}{*}q)
\begin{DoxyCompactList}\small\item\em Convert eular angle to quaternion. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\Hypertarget{ins__task_8c_ae8190ca21220538746a422536e9161af}\label{ins__task_8c_ae8190ca21220538746a422536e9161af} 
const float {\bfseries xb} \mbox{[}3\mbox{]} = \{1, 0, 0\}
\item 
\Hypertarget{ins__task_8c_a6cd4e6b14e528c9821cd1d45110d2cd9}\label{ins__task_8c_a6cd4e6b14e528c9821cd1d45110d2cd9} 
const float {\bfseries yb} \mbox{[}3\mbox{]} = \{0, 1, 0\}
\item 
\Hypertarget{ins__task_8c_a8766adb87d571c09bcfea9518b747cc9}\label{ins__task_8c_a8766adb87d571c09bcfea9518b747cc9} 
const float {\bfseries zb} \mbox{[}3\mbox{]} = \{0, 0, 1\}
\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
\begin{DoxyAuthor}{Author}
Wang Hongxi 

annotation and modificaiton by neozng 
\end{DoxyAuthor}
\begin{DoxyVersion}{Version}
V2.\+0.\+0 
\end{DoxyVersion}
\begin{DoxyDate}{Date}
2022/2/23 
\end{DoxyDate}
\begin{DoxyAttention}{Attention}

\end{DoxyAttention}


\label{doc-func-members}
\Hypertarget{ins__task_8c_doc-func-members}
\doxysubsection{Function Documentation}
\Hypertarget{ins__task_8c_a151377c6cfa1152d7642d42cd7dd5d3d}\index{ins\_task.c@{ins\_task.c}!BodyFrameToEarthFrame@{BodyFrameToEarthFrame}}
\index{BodyFrameToEarthFrame@{BodyFrameToEarthFrame}!ins\_task.c@{ins\_task.c}}
\doxysubsubsection{\texorpdfstring{BodyFrameToEarthFrame()}{BodyFrameToEarthFrame()}}
{\footnotesize\ttfamily \label{ins__task_8c_a151377c6cfa1152d7642d42cd7dd5d3d} 
void Body\+Frame\+To\+Earth\+Frame (\begin{DoxyParamCaption}\item[{const float \texorpdfstring{$\ast$}{*}}]{vec\+BF}{, }\item[{float \texorpdfstring{$\ast$}{*}}]{vec\+EF}{, }\item[{float \texorpdfstring{$\ast$}{*}}]{q}{}\end{DoxyParamCaption})}



Transform 3dvector from Body\+Frame to Earth\+Frame. 

机体系到惯性系的变换函数


\begin{DoxyParams}{Parameters}
{\em \mbox{[}1\mbox{]}} & vector in Body\+Frame \\
\hline
{\em \mbox{[}2\mbox{]}} & vector in Earth\+Frame \\
\hline
{\em \mbox{[}3\mbox{]}} & quaternion \\
\hline
\end{DoxyParams}
\Hypertarget{ins__task_8c_add6f841604e6b40025533d6e58d74ac8}\index{ins\_task.c@{ins\_task.c}!EarthFrameToBodyFrame@{EarthFrameToBodyFrame}}
\index{EarthFrameToBodyFrame@{EarthFrameToBodyFrame}!ins\_task.c@{ins\_task.c}}
\doxysubsubsection{\texorpdfstring{EarthFrameToBodyFrame()}{EarthFrameToBodyFrame()}}
{\footnotesize\ttfamily \label{ins__task_8c_add6f841604e6b40025533d6e58d74ac8} 
void Earth\+Frame\+To\+Body\+Frame (\begin{DoxyParamCaption}\item[{const float \texorpdfstring{$\ast$}{*}}]{vec\+EF}{, }\item[{float \texorpdfstring{$\ast$}{*}}]{vec\+BF}{, }\item[{float \texorpdfstring{$\ast$}{*}}]{q}{}\end{DoxyParamCaption})}



Transform 3dvector from Earth\+Frame to Body\+Frame. 

惯性系转换到机体系


\begin{DoxyParams}{Parameters}
{\em \mbox{[}1\mbox{]}} & vector in Earth\+Frame \\
\hline
{\em \mbox{[}2\mbox{]}} & vector in Body\+Frame \\
\hline
{\em \mbox{[}3\mbox{]}} & quaternion \\
\hline
\end{DoxyParams}
\Hypertarget{ins__task_8c_ab9879d429b498cb40bfb7027a771d12b}\index{ins\_task.c@{ins\_task.c}!EularAngleToQuaternion@{EularAngleToQuaternion}}
\index{EularAngleToQuaternion@{EularAngleToQuaternion}!ins\_task.c@{ins\_task.c}}
\doxysubsubsection{\texorpdfstring{EularAngleToQuaternion()}{EularAngleToQuaternion()}}
{\footnotesize\ttfamily \label{ins__task_8c_ab9879d429b498cb40bfb7027a771d12b} 
void Eular\+Angle\+To\+Quaternion (\begin{DoxyParamCaption}\item[{float}]{Yaw}{, }\item[{float}]{Pitch}{, }\item[{float}]{Roll}{, }\item[{float \texorpdfstring{$\ast$}{*}}]{q}{}\end{DoxyParamCaption})}



Convert eular angle to quaternion. 

ZYX欧拉角转换为四元数 \Hypertarget{ins__task_8c_a12a2c8b057bc73a18dc7765de080bd27}\index{ins\_task.c@{ins\_task.c}!QuaternionToEularAngle@{QuaternionToEularAngle}}
\index{QuaternionToEularAngle@{QuaternionToEularAngle}!ins\_task.c@{ins\_task.c}}
\doxysubsubsection{\texorpdfstring{QuaternionToEularAngle()}{QuaternionToEularAngle()}}
{\footnotesize\ttfamily \label{ins__task_8c_a12a2c8b057bc73a18dc7765de080bd27} 
void Quaternion\+To\+Eular\+Angle (\begin{DoxyParamCaption}\item[{float \texorpdfstring{$\ast$}{*}}]{q}{, }\item[{float \texorpdfstring{$\ast$}{*}}]{Yaw}{, }\item[{float \texorpdfstring{$\ast$}{*}}]{Pitch}{, }\item[{float \texorpdfstring{$\ast$}{*}}]{Roll}{}\end{DoxyParamCaption})}



Convert quaternion to eular angle. 

四元数转换成欧拉角 ZYX \Hypertarget{ins__task_8c_af69cef46084fc1f1f7f41a5e48f5a7e9}\index{ins\_task.c@{ins\_task.c}!QuaternionUpdate@{QuaternionUpdate}}
\index{QuaternionUpdate@{QuaternionUpdate}!ins\_task.c@{ins\_task.c}}
\doxysubsubsection{\texorpdfstring{QuaternionUpdate()}{QuaternionUpdate()}}
{\footnotesize\ttfamily \label{ins__task_8c_af69cef46084fc1f1f7f41a5e48f5a7e9} 
void Quaternion\+Update (\begin{DoxyParamCaption}\item[{float \texorpdfstring{$\ast$}{*}}]{q}{, }\item[{float}]{gx}{, }\item[{float}]{gy}{, }\item[{float}]{gz}{, }\item[{float}]{dt}{}\end{DoxyParamCaption})}



Update quaternion. 

四元数更新函数,即实现dq/dt=0.\+5Ωq 